package tedu.study.day03;
//运算符的演示
public class OperDemo {
    public static void main(String[] args) {
        /*
        2.1)单独使用时，在前在后一样
        2.2)被使用时，在前在后不一样
           a++的值为a----------(a--的值为a)
           ++a的值为a+1--------(--a的值为a-1)
         */
        /*int a=5,b=5;
        a--;
        --b;
        System.out.println(a);
        System.out.println(b);

        int a1=10,b1=10;
        int c1 = --a1; //1）将++a1的值11赋值给c1,2)a1自增1变为11
        int d1 = b1--; //2) 将b1++的值10赋值给d1,2)b1自增1变为11
        System.out.println(a1);
        System.out.println(b1);
        System.out.println(c1);
        System.out.println(d1);

        System.out.println(a1++);
        System.out.println(a1);

         */

        /*//关系运算
        int a=5,b=10,c=5;
        boolean b1 = a>b;
        System.out.println(b1); //false
        System.out.println(c<b);//true
        System.out.println(a>=c);//true
        System.out.println(a<=b);//true
        System.out.println(a==c);//true
        System.out.println(a!=c);//false

        System.out.println(a+c>b); //false
        System.out.println(a%2==0);//false
        System.out.println(a++>5);//false
        System.out.println(a++>5);//true

         */


        //逻辑运算
        //int a=5,b=10,c=5;
        /*boolean b3 = a>b && c++>2;//false &&
        System.out.println(b3);//false
        System.out.println(c);//5
         */
         /*
        boolean b4 = a<b || c++>2;//true ||
        System.out.println(b4);//true
        System.out.println(c);//5
        boolean b5 = a>b || c++>2;//false ||
        System.out.println(b4);//true
        System.out.println(c);//6
        */


        /*
        //||
        System.out.println(b>=a || b<c);//true || false
        System.out.println(b<=c || b>a);//false || true
        System.out.println(b!=c || a<b);//true || true
        System.out.println(a==b || c>b);//false || false
        //!
        boolean b2 = !(a<b);//!true = false
        System.out.println(b2);//false
        System.out.println(!(a<b));//!true = false

         */

        //&&
        /*boolean b1 = b>=a && b<c;
        System.out.println(b1); //true&&false
        System.out.println(b<=c && b>a);//false && true
        System.out.println(a==b && c>b);//false && false
        System.out.println(b!=c && a<b);//true && true

        System.out.println("中文");

         */

        //扩展赋值运算符自带强转功能：+=、-=、*=、/=、%=
        /*
        short s = 5;
        //s = s+10;//编译错误，需强转，改为 s = (short)(s+10);
        s += 10; //相当于： s = (short)(s+10);

        int a = 5;
        a += 10;//相当于 a = (int)(a+10);
        System.out.println(a);
        a *= 2;
        System.out.println(a);
        a /= 6;
        System.out.println(a);
        a %= 2;
        System.out.println(a);
        a -= 3;
        System.out.println(a);

         */

        //字符串连接符+
        //1.1)若两边为数字，则做加法运算
        //1.2)若两边出现了字符串，则做字符串连接
        //1.3)任何数据与字符串相连，结果都是字符串类型
        /*int age = 36;
        System.out.println("age=");
        System.out.println(age);
        System.out.println("age="+age);
        System.out.println("我的年龄是"+age);
        System.out.println("我今年"+age+"岁了");

        String name = "WKJ";
        System.out.println("name="+name);
        System.out.println("大家好，我叫"+name);
        System.out.println("大家好，我叫"+name+",今年"+age+"岁了。");

         */
        /*System.out.println(10+20+""+30);//3030
        System.out.println(""+10+20+30);//102030
        System.out.println(10+20+30+"");//60

         */
        //boolean?true:false
        int num = 5;
        int flag = num>0?1:-1;
        System.out.println(flag);//1

        int a=8,b=59;
        int max = a<b?b:a;
        System.out.println("max="+max);//获取最大值

    }
}
